home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / ply15dat.zip / ALLPRIMS.PI next >
Text File  |  1992-11-06  |  7KB  |  255 lines

  1. // Sample file demonstrating all (well almost all) of the primitives that
  2. // exist in Polyray.
  3. // Author - Alexander Enzmann
  4.  
  5. viewpoint {
  6.    from <0,150,-200>
  7.    at <0,0,0>
  8.    up <0,1,0>
  9.    angle 8.5
  10.    resolution 720, 450
  11.    aspect 1.6
  12.    }
  13.  
  14. background midnightblue
  15.  
  16. light <0.5, 0.5, 0.5>, <0, 50, -10>
  17. spot_light white, < 20, 10, -20>, < 15,0,-15>, 5, 40, 42
  18. spot_light white, <-20, 10, -20>, <-15,0,-15>, 5, 40, 42
  19.  
  20. include "..\colors.inc"
  21. include "..\texture.inc"
  22.  
  23. // In alphabetical order even...
  24.  
  25. // Start with some flags so we can turn the individual
  26. // objects on and off.  This is real useful during
  27. // testing.
  28. define bezier_flag     1
  29. define blob_flag       1
  30. define box_flag        1
  31. define cone_flag       1
  32. define cylinder_flag   1
  33. define disc_flag       1
  34. define function_flag   1
  35. define height_flag     1
  36. define lathe_flag      1
  37. define parabola_flag   1
  38. define polygon_flag    1
  39. define polynomial_flag 1
  40. define sweep1_flag     1
  41. define sweep2_flag     1
  42. define sphere_flag     1
  43. define torus_flag      1
  44.  
  45. // Get the definition of a teapot
  46. include "teapot.inc"
  47. if (bezier_flag == 1) {
  48.    teapot {
  49.       rotate <0, 20, 0>
  50.       scale <1.5, 1.5, 1.5>
  51.       translate <22, 0, 2>
  52.       shiny_red
  53.       }
  54.    }
  55.  
  56. if (blob_flag == 1)
  57. // Multipoint blob.  This blob is carved from white marble.
  58. object {
  59.    blob 0.5:
  60.       1.0, 1.0, <0.75, 0, 0>,
  61.       1.0, 1.0, <0.75*cos(radians(120)), 0.75*sin(radians(120)), 0>,
  62.       1.0, 1.0, <0.75*cos(radians(240)), 0.75*sin(radians(240)), 0>,
  63.       1.0, 1.0, <0.2, 1.2, 0.8>,
  64.       1.0, 1.0, <-0.2, 1.2, -0.8>,
  65.       1.0, 1.0, <0.3, -1, -0.7>,
  66.       1.0, 1.0, <0, 0, 0>,
  67.       1.0, 1.0, <-0.1, 0, 0.3>,
  68.       1.0, 1.0, <0,-2, -0.5>,
  69.       1.0, 1.0, <-0.5, -1, -1.4>
  70.    u_steps 20
  71.    v_steps 20
  72.    white_marble
  73.    translate <0, 2, 0>
  74.    scale <1.5, 1, 2>
  75.    rotate <0, 80, 0>
  76.    translate <-12, 0, -20>
  77.    }
  78.  
  79. if (box_flag == 1)
  80. // Box primitive
  81. object {
  82.    box <-2, 0,-2>, <2, 2, 2>
  83.    rotate <40, 30, 0>
  84.    translate <-5, 3, 16>
  85.    matte_blue
  86.    }
  87.  
  88. if (cone_flag == 1)
  89. // Cone primitive
  90. object {
  91.    cone <0, 0, 0>, 3, <0, 6, 0>, 0
  92.    translate <8, 0, 16>
  93.    reflective_gold
  94.    }
  95.  
  96. if (cylinder_flag == 1)
  97. // A Cylinder that has an image wrapped around it
  98. object {
  99.    cylinder <0, 0, 0>, <0, 6, 0>, 3
  100.    texture {
  101.       special surface {
  102.          color cylindrical_imagemap(image("cylimg.tga"), P, 1)
  103.          ambient 0.5
  104.          diffuse 0.5
  105.          }
  106.       scale <1, 6, 1>
  107.       }
  108.    rotate <0,-90, 0>
  109.    translate <-20, 0, 0>
  110.    }
  111.  
  112. if (disc_flag == 1)
  113. // Disc primitive.  These are so boring by themselves that
  114. // I've added some ripple to the surface just to make it
  115. // a little more interesting.
  116. object {
  117.    disc <0, 0, 0>, <0, 1, 0>, 4
  118.    blue_ripple
  119.    rotate <-20, -30, 0>
  120.    translate <-5, 3, -10>
  121.    }
  122.  
  123. if (height_flag == 1)
  124. object {
  125.    height_fn 20, 20, -4, 4, -4, 4,
  126.       4 * cos(3 * sqrt(x^2 + z^2)) * exp(-0.5 * sqrt(x^2 + z^2))
  127.    shiny_green
  128.    translate <15, 2, -10>
  129.    }
  130.  
  131. if (function_flag == 1)
  132. // Implicit function.  This surface is nice and wavy.
  133. // It is small in this image cause these things take
  134. // forever to render.
  135. object {
  136.      object { function y - sin(3 * x * z) }
  137.    & object { box <-2, -1, -2>, <2, 1, 2> }
  138.    bounding_box <-2, -1, -2>, <2, 1, 2>
  139.    shiny_yellow
  140.    scale <1.5, 1, 1.5>
  141.    rotate <0, -30, 0>
  142.    translate <-10, 2.2, 5>
  143.    }
  144.  
  145. if (lathe_flag == 1)
  146. // Lathe primitive
  147. object {
  148.    lathe 2, <0, 1, 0>, 5,
  149.         <3, 0>, <0.5, 2>, <4, 3>, <3, 7>, <0, 9>
  150.    scale <0.8, 0.8, 0.8>
  151.    shiny_coral
  152.    translate <0, 0, 8>
  153.    }
  154.  
  155. if (parabola_flag == 1)
  156. // Parabola primitive.  Sort of like a salt shaker in this
  157. // orientation.
  158. object {
  159.    parabola <0, 6, 0>, <0, 0, 0>, 3
  160.    translate <16, 0, 16>
  161.    steel_blue
  162.    }
  163.  
  164. if (polynomial_flag == 1)
  165. // Polynomial surface.  This is the devils curve, one of
  166. // my personal favorites.
  167. object {
  168.      object { polynomial x^4 + 2*x^2*z^2 - 0.36*x^2 - y^4 + 0.25*y^2 + z^4 }
  169.    & object { box <-2, -2, -0.5>, <2, 2, 0.5> }
  170.    bounding_box <-2, -2, -0.5>, <2, 2, 0.5>
  171.    scale <2, 2, 2>
  172.    rotate <20, 10, 0>
  173.    shiny_red
  174.    translate <-15, 4, -10>
  175.    }
  176.  
  177. if (sphere_flag == 1)
  178. // Create a sphere with a checker texture
  179. object {
  180.    sphere <0, 0, 0>, 3
  181.    texture {
  182.       checker shiny_red, shiny_blue
  183.       }
  184.    translate <-15, 3, 16>
  185.    }
  186.  
  187. // Sweep surfaces - there are several so that the various
  188. // forms can be demonstrated.
  189. define r0 2
  190. define r1 4
  191. define dt (2.0 * 3.14159265) / 14
  192.  
  193. if (sweep1_flag == 1)
  194. // First sweep is made from connected line segments
  195. object {
  196.    sweep 1, <0, 1, 0>, 15,
  197.          <r0*cos( 1*dt), r0*sin( 1*dt)>, <r1*cos( 2*dt), r1*sin( 2*dt)>,
  198.          <r0*cos( 3*dt), r0*sin( 3*dt)>, <r1*cos( 4*dt), r1*sin( 4*dt)>,
  199.          <r0*cos( 5*dt), r0*sin( 5*dt)>, <r1*cos( 6*dt), r1*sin( 6*dt)>,
  200.          <r0*cos( 7*dt), r0*sin( 7*dt)>, <r1*cos( 8*dt), r1*sin( 8*dt)>,
  201.          <r0*cos( 9*dt), r0*sin( 9*dt)>, <r1*cos(10*dt), r1*sin(10*dt)>,
  202.          <r0*cos(11*dt), r0*sin(11*dt)>, <r1*cos(12*dt), r1*sin(12*dt)>,
  203.          <r0*cos(13*dt), r0*sin(13*dt)>, <r1*cos(14*dt), r1*sin(14*dt)>,
  204.          <r0*cos( 1*dt), r0*sin( 1*dt)>
  205.    translate <0, 0, -20>
  206.    matte_red
  207.    }
  208.  
  209. if (sweep2_flag == 1)
  210. // Second sweep is made from connected quadratic splines.
  211. object {
  212.    sweep 2, <0, 1, 0>, 16,
  213.       <0, 0>, <0, 1>, <-1, 1>, <-1, -1>, <2, -1>, <2, 3>,
  214.       <-4, 3>, <-4, -4>, <4, -4>, <4, -11>, <-2, -11>,
  215.       <-2, -7>, <2, -7>, <2, -9>, <0, -9>, <0, -8>
  216.    translate <0, 0, -4>
  217.    rotate <0,-45, 0>
  218.    translate <10, 0, -18>
  219.    shiny_yellow
  220.    }
  221.  
  222. if (torus_flag == 1)
  223. // Torus primitive.  Just for grins lets make it out of wood.
  224. object {
  225.    torus sqrt(40), sqrt(12), <0, 0, 0>, <0, 1, 0>
  226.    root_solver Sturm
  227.    wooden { scale <8, 8, 8> rotate <30, 20, 0> }
  228.    scale <0.3, 0.3, 0.3>
  229.    rotate <-40, 0, 0>
  230.    translate <10, 3, 0>
  231.    }
  232.  
  233. // Make a hexagonal polygon with hexagonal texturing
  234. define rp 30                         // Radius of the polygon
  235. define ang -(2.0 * 3.14159265) / 6   // 60 degrees in radians
  236. if (polygon_flag == 1)
  237. object {
  238.    polygon 6,
  239.          <rp*cos( 1*ang), 0, rp*sin( 1*ang)>,
  240.          <rp*cos( 2*ang), 0, rp*sin( 2*ang)>,
  241.          <rp*cos( 3*ang), 0, rp*sin( 3*ang)>,
  242.          <rp*cos( 4*ang), 0, rp*sin( 4*ang)>,
  243.          <rp*cos( 5*ang), 0, rp*sin( 5*ang)>,
  244.          <rp*cos( 6*ang), 0, rp*sin( 6*ang)>
  245.    texture {
  246.       hexagon
  247.          xz_wheel_texture,
  248.          sapphire_agate,
  249.          whorl_texture
  250.       scale <6, 6, 6>
  251.       }
  252.    translate <0, -0.05, 0>
  253.    }
  254.  
  255.